﻿using BangleCMS.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BangleCMS.Model;
using BangleCMS.BLL;

public partial class MasterPage_Content : System.Web.UI.MasterPage
{
    t_webnavBLL nav_bll = new t_webnavBLL();

    #region 属性
    public string PageCode
    {
        get
        {
            return Request.QueryString["t"] == null ? "" : Request.QueryString["t"];
        }
    }

    private t_webnav _getleftwebnavparent;
    public t_webnav GetLeftWebnavParent
    {
        get
        {
            if (_getleftwebnavparent == null)
            {
                t_webnav nav = nav_bll.GetModelList(string.Format(" Code='{0}' ", PageCode)).FirstOrDefault();
                if (nav==null)
                {
                    return new t_webnav();
                }
                if (nav.ParentId > 0)
                {
                    _getleftwebnavparent = nav_bll.GetModelList(string.Format(" WebnavId={0} ", nav.ParentId)).FirstOrDefault();
                }
                else
                {
                    _getleftwebnavparent = nav;
                }
            }
            if (_getleftwebnavparent == null)
            {
                _getleftwebnavparent = new t_webnav();
            }
            return _getleftwebnavparent;
        }
    }

    public List<t_webnav> GetLeftWebnavList()
    {
        List<t_webnav> list = nav_bll.GetModelList(string.Format(" ParentId={0} ", GetLeftWebnavParent.WebNavId));
        if (list != null && list.Count > 0)
        {
            return list;
        }
        return new List<t_webnav>() { GetLeftWebnavParent };
    }
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
}
